#!/bin/bash

file=$1
opt="-Dspring.profiles.active=test"
java -jar $opt $file &>app.log &

while :
do
	if test ! -e $file
	then
		echo "$file not exist"
		sleep 5
		continue
	fi
	old=$(stat --format=%Z $file)
	sleep 5
	new=$(stat --format=%Z $file)
	if test ! $old = $new
	then
		echo “杀死原有进程”
		kill $(ps aux | grep $file | grep java | awk '{print $2}')
		sleep 5
		echo “重新启动$file”
		java -jar $opt $file &>app.log &
	fi
done
